package com.geekhome.player.global.common;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Copyright © 2018年 ziniuxiaozhu. All rights reserved.
 *
 * @Author 临江仙 hzqiuxm@163.com
 * 定义数据返回的统一格式
 * @Date 2018/8/3 10:04
 */
public interface SysConst {
    final class ReturnCode {
        /** 请求成功 */
        public static final int OK = 200;
        /** 参数错误 */
        public static final int F_201 = 201;
        /** 无操作权限 */
        public static final int F_202 = 202;
        /** 不支持该操作 */
        public static final int F_203 = 203;
        /** 无需重复操作 */
        public static final int F_204 = 204;
        /** 数据解析失败 */
        public static final int F_205 = 205;
        /** 超出最大支持的大小 */
        public static final int F_206 = 206;

        /** Token已过期 */
        public static final int F_101 = 101;
        /** Token格式错误 */
        public static final int F_102 = 102;
        /** Token没有被正确构造 */
        public static final int F_103 = 103;
        /** Token签名失败 */
        public static final int F_104 = 104;
        /** Token非法参数异常 */
        public static final int F_105 = 105;
        /** Token缺少必要认证参数 */
        public static final int F_106 = 106;
        /** Token颁发认证机构不通过 */
        public static final int F_107 = 107;
        /** Token未知原因验证失败 */
        public static final int F_108 = 108;

        /** 未查到数据 */
        public static final int F_301 = 301;
        /**  */
        public static final int F_302 = 302;
        /** 系统保存失败 */
        public static final int F_303 = 303;
    }

    /**
     * 规则配置
     */
    final class RuleConf {
        /**
         * 这些规则从规则配置集合中获取，这里测试先写成固定的
         */

        /**
         * 课程发布时指定规则
         */
        public static final String COURSE_PUBLISH = "COURSE_PUBLISH_20171031";
    }

    /** 用户状态 */
    final class UserStage {
        /** 待审核 */
        public static final byte STAGE_0 = 0;
        /** 正常 */
        public static final byte STAGE_1 = 1;
        /** 保留 */
        public static final byte STAGE_2 = 2;
    }

    /** 用户权限 */
    final class UserRoles {
        /** 普通用户 */
        public static final String USER = "ROLE_USER";
        /** 超级管理员 */
        public static final String ADMIN = "ROLE_ADMIN";
    }

    /** 课程阶段 */
    final class CourseStage {
        /** 发布 */
        public static final byte PUBLISH = 0;
        /** 审核 */
        public static final byte REVIEW = 1;
        /** 保留 */
        public static final byte STAY = 2;
        /** 报名 */
        public static final byte SIGNUP = 3;
        /** 闭课 */
        public static final byte CLOSED = 4;
        /** 开课 */
        public static final byte START = 5;
        /** 结课 */
        public static final byte COMPLETE = 6;
        /** 公开 */
        public static final byte OPEN = 7;

        public static final Map<Byte, String> mapper;
        static {
            mapper = new HashMap<>();
            mapper.put(PUBLISH, "发布中");
            mapper.put(REVIEW, "审核中");
            mapper.put(STAY, "已保留");
            mapper.put(SIGNUP, "报名中");
            mapper.put(CLOSED, "已闭课");
            mapper.put(START, "开课中");
            mapper.put(COMPLETE, "已结课");
            mapper.put(OPEN, "已公开");
        }
    }

    /**
     * 资源目录
     */
    final class ResDir {
        /** 课程封面 */
        public static final String COURSE_COVER = "cover/";
        /** 课程PPT */
        public static final String COURSE_PPT = "ppt/";
        /** 用户头像 */
        public static final String USER_AVATAR = "avatar/";
    }

    public static final String ROLES = "roles";
    public static final String AUTHORITY = "authority";
    //普通用户角色
    public static final String ROLE_USER = "ROLE_USER";
    //访客角色
    public static final List<GrantedAuthority> guestLists = new ArrayList<GrantedAuthority>(){{add(new SimpleGrantedAuthority("GUEST"));}};



}
